﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SimpleWeather.WeatherService;
using StyleMVVM.Data;
using StyleMVVM.Data.Transform;
using StyleMVVM.LanguageExtensions;
using StyleMVVM.Utilities;

namespace SimpleWeather.BusinessEntities
{
	public class CompleteDayForecast : ComplexObject 
	{
		private System.DateTime dateField;
		private short weatherIDField;
		private string descriptionField;
		private PredictedTempsForDay temperaturesField;
		private ProbabilityOfPrecipitation probabilityOfPrecipiationField;
		private GenericWeatherDescription weatherDescription;

		public string CityDisplayName
		{
			get
			{
				CityWeather cityWeather = this.GetRoot() as CityWeather;

				if(cityWeather != null)
				{
					return cityWeather.CityDisplayName;
				}

				return null;
			}
		}

		public string DateDisplay
		{
			get
			{
				if(Date.Date == DateTime.Now.Date)
				{
					return string.Format("Today {0}/{1}", Date.Month, Date.Day);
				}

				return string.Format("{0} {1}/{2}", Date.DayOfWeek, Date.Month, Date.Day);
			}
		}

		public System.DateTime Date
		{
			get
			{
				return this.dateField;
			}
			set
			{
				SetProperty(ref dateField, value);
			}
		}

		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute(Order = 1)]
		public short WeatherID
		{
			get
			{
				return this.weatherIDField;
			}
			set { SetProperty(ref weatherIDField, value); }
		}

		[Transform(TransformName = "Deciption",TransformType = typeof(Forecast))]
		public string Description
		{
			get
			{
				return this.descriptionField;
			}
			set
			{
				SetProperty(ref descriptionField, value);
			}
		}

		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute(Order = 3)]
		public PredictedTempsForDay Temperatures
		{
			get
			{
				return this.temperaturesField;
			}
			set
			{
				SetProperty(ref temperaturesField, value);
			}
		}

		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute(Order = 4)]
		public ProbabilityOfPrecipitation ProbabilityOfPrecipiation
		{
			get
			{
				return this.probabilityOfPrecipiationField;
			}
			set
			{
				SetProperty(ref probabilityOfPrecipiationField, value);
			}
		}

		public GenericWeatherDescription WeatherDescription
		{
			get { return weatherDescription; }
			set
			{
				SetProperty(ref weatherDescription, value);
			}
		}

		public string ImageURL 
		{ 
			get
			{
				if (WeatherDescription != null)
				{
					return weatherDescription.PictureURL;
				}

				return null;
			}
		}
	}
}
